<%@ page import="employee.Employee" %><%--
  Created by IntelliJ IDEA.
  User: 王宇航
  Date: 2023/3/10
  Time: 22:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>userPage</title>
</head>
<body>
<h2 style="color: aquamarine">
    <%
        String name = (String) session.getAttribute("name");
        Object obj = session.getAttribute("role");
        int role = -1;
        if ( obj!= null){
            role= (int) session.getAttribute("role");
        }
        if (name != null && role == 0 ){
            out.println(name);
        }else {
            session.setAttribute("error","Can't to Access userPage!");
            response.sendRedirect("index.jsp");
        }
    %>
</h2>

<hr/>
<table style="border:solid">
    <tr>
        <th>id</th>
        <th>name</th>
        <th>age</th>
        <th>gender</th>
    </tr>
    <%
      Employee employee = (Employee) session.getAttribute("employee");
      if (employee != null){
          out.println("<tr><td>"+employee.getId()+"</td>");
          out.println("<td>"+employee.getName()+"</td>");
          out.println("<td>"+employee.getAge()+"</td>");
          out.println("<td>"+employee.getGender()+"</td></tr>");
      }else {
          out.println("Nothing in Employee!");
      }
    %>
</table>
<hr/>
<a href="/employee?action=SignOut">Sign Out</a>
</body>
</html>
